package config

import (
	"io/ioutil"
	"log"

	"gopkg.in/yaml.v2"

	"test.com/app/headlers"
)

type MysqlConfig struct {
	User     string `yaml:"user"`
	Port     int16  `yaml:"port"`
	Password string `yaml:"password"`
	Database string `yaml:"database"`
}

func GetMysqlConfig() MysqlConfig {
	file := "./mysql.yaml"
	var config MysqlConfig
	content, err := ioutil.ReadFile(file)
	headlers.CheckErr(err)
	if err = yaml.Unmarshal(content, &config); err != nil {
		log.Fatalln(err)
	}
	return config
}
